package com.yuanyu.server.impl;

import com.yuanyu.common.util.AssertUtil;
import com.yuanyu.common.util.CopyUtil;
import com.yuanyu.mapper.mysqlMapper.Dry_Pump_Unit_Electrical_Control_System_Inspection_Record.Dry_Pump_Unit_Electrical_Control_System_Inspection_Record_1_Mapper;
import com.yuanyu.mapper.mysqlMapper.Dry_Pump_Unit_Electrical_Control_System_Inspection_Record.Dry_Pump_Unit_Electrical_Control_System_Inspection_Record_Mapper;
import com.yuanyu.mapper.mysqlMapper.MainTable_Mapper;
import com.yuanyu.model.dto.Dry_Pump_Unit_Electrical_Control_System_Inspection_RecordDTO;
import com.yuanyu.model.entity.Dry_Pump_Unit_Electrical_Control_System_Inspection_Record.Dry_Pump_Unit_Electrical_Control_System_Inspection_Record;
import com.yuanyu.model.entity.Dry_Pump_Unit_Electrical_Control_System_Inspection_Record.Dry_Pump_Unit_Electrical_Control_System_Inspection_Record_1;
import com.yuanyu.model.vo.Dry_Pump_Unit_Electrical_Control_System_Inspection_RecordVO;
import com.yuanyu.server.ITestPart9Server;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;

@Service
@Transactional
public class TestPart9ServerImpl implements ITestPart9Server {
    @Autowired
    private Dry_Pump_Unit_Electrical_Control_System_Inspection_Record_Mapper dryPumpUnitElectricalControlSystemInspectionRecordMapper;
    @Autowired
    private Dry_Pump_Unit_Electrical_Control_System_Inspection_Record_1_Mapper dryPumpUnitElectricalControlSystemInspectionRecord1Mapper;
    @Autowired
    private MainTable_Mapper mainTableMapper;


    @Override
    public String test() {
        return "测试成功";
    }

    @Override
    public String test9(Dry_Pump_Unit_Electrical_Control_System_Inspection_RecordVO dryPumpUnitElectricalControlSystemInspectionRecordVO) {
        Dry_Pump_Unit_Electrical_Control_System_Inspection_Record test = dryPumpUnitElectricalControlSystemInspectionRecordMapper.selTableTime(dryPumpUnitElectricalControlSystemInspectionRecordVO.getInput_Case());
        AssertUtil.isNull(test,"Case已存在,如需修改内容请前往后台修改");

        Dry_Pump_Unit_Electrical_Control_System_Inspection_Record dryPumpUnitElectricalControlSystemInspectionRecord = new Dry_Pump_Unit_Electrical_Control_System_Inspection_Record();
        Dry_Pump_Unit_Electrical_Control_System_Inspection_Record_1 dryPumpUnitElectricalControlSystemInspectionRecord1 = new Dry_Pump_Unit_Electrical_Control_System_Inspection_Record_1();

        CopyUtil.copyClass(dryPumpUnitElectricalControlSystemInspectionRecordVO, dryPumpUnitElectricalControlSystemInspectionRecord);
        dryPumpUnitElectricalControlSystemInspectionRecord.setCreatedAt(LocalDateTime.now());
        dryPumpUnitElectricalControlSystemInspectionRecord.setUpdatedAt(LocalDateTime.now());
        CopyUtil.copyClass(dryPumpUnitElectricalControlSystemInspectionRecordVO, dryPumpUnitElectricalControlSystemInspectionRecord1);

        System.out.println(dryPumpUnitElectricalControlSystemInspectionRecord);
        System.out.println(dryPumpUnitElectricalControlSystemInspectionRecord1);

        int i = dryPumpUnitElectricalControlSystemInspectionRecordMapper.addTableTime(dryPumpUnitElectricalControlSystemInspectionRecord);
        int i1 = dryPumpUnitElectricalControlSystemInspectionRecord1Mapper.addTable1(dryPumpUnitElectricalControlSystemInspectionRecord1);

        AssertUtil.isTrue(i == 1 && i1 == 1,"添加数据出现异常,请检查");
        mainTableMapper.updateByCaseFormStartTime(dryPumpUnitElectricalControlSystemInspectionRecordVO.getInput_Case());
        return "添加成功";
    }

    @Override
    public String updateTable9(Dry_Pump_Unit_Electrical_Control_System_Inspection_RecordVO dryPumpUnitElectricalControlSystemInspectionRecordVO) {
        Dry_Pump_Unit_Electrical_Control_System_Inspection_Record dryPumpUnitElectricalControlSystemInspectionRecord = new Dry_Pump_Unit_Electrical_Control_System_Inspection_Record();
        Dry_Pump_Unit_Electrical_Control_System_Inspection_Record_1 dryPumpUnitElectricalControlSystemInspectionRecord1 = new Dry_Pump_Unit_Electrical_Control_System_Inspection_Record_1();

        CopyUtil.copyClass(dryPumpUnitElectricalControlSystemInspectionRecordVO, dryPumpUnitElectricalControlSystemInspectionRecord);
        dryPumpUnitElectricalControlSystemInspectionRecord.setUpdatedAt(LocalDateTime.now());
        CopyUtil.copyClass(dryPumpUnitElectricalControlSystemInspectionRecordVO, dryPumpUnitElectricalControlSystemInspectionRecord1);

        int i = dryPumpUnitElectricalControlSystemInspectionRecordMapper.updateTableTime(dryPumpUnitElectricalControlSystemInspectionRecord);
        int i1 = dryPumpUnitElectricalControlSystemInspectionRecord1Mapper.updateTable1(dryPumpUnitElectricalControlSystemInspectionRecord1);

        AssertUtil.isTrue(i == 1 && i1 == 1,"表9修改数据出现异常,请检查");
        return "修改成功";
    }

    @Override
    public Dry_Pump_Unit_Electrical_Control_System_Inspection_RecordDTO getTest9(String Case) {
        Dry_Pump_Unit_Electrical_Control_System_Inspection_Record dryPumpUnitElectricalControlSystemInspectionRecord = dryPumpUnitElectricalControlSystemInspectionRecordMapper.selTableTime(Case);
        if (dryPumpUnitElectricalControlSystemInspectionRecord == null)return null;
        Dry_Pump_Unit_Electrical_Control_System_Inspection_Record_1 dryPumpUnitElectricalControlSystemInspectionRecord1 = dryPumpUnitElectricalControlSystemInspectionRecord1Mapper.selTable1(Case);

        Dry_Pump_Unit_Electrical_Control_System_Inspection_RecordDTO dryPumpUnitElectricalControlSystemInspectionRecordDTO = new Dry_Pump_Unit_Electrical_Control_System_Inspection_RecordDTO();
        CopyUtil.copyClass(dryPumpUnitElectricalControlSystemInspectionRecord,dryPumpUnitElectricalControlSystemInspectionRecordDTO);
        CopyUtil.copyClass(dryPumpUnitElectricalControlSystemInspectionRecord1,dryPumpUnitElectricalControlSystemInspectionRecordDTO);
        return dryPumpUnitElectricalControlSystemInspectionRecordDTO;
    }
}
